<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="6" :sm="8">
            <a-form-item label="数据编码">
              <a-input placeholder="请输入数据编码" v-model="queryParam.code"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="数据名称">
              <a-input placeholder="请输入数据名称" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleDetail" type="primary" icon="plus">新增</a-button> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="default"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <template slot="dataStatus" slot-scope="text">
            <span :style="{'color':text=='正高级'?'red':''}">{{text}}</span>
        </template>
        <!-- <template slot="createTime" slot-scope="text">
          <span v-if="text !== '' && text !== null">{{moment(text).format("YYYY-MM-DD HH:mm:ss")}}</span>
        </template> -->
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <dataManagement-modal ref="modalForm" @ok="modalFormOk"></dataManagement-modal>
  </a-card>
</template>

<script>
  import moment from 'moment'
  import DataManagementModal from './modules/DataManagementModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'

  export default {
    name: 'SysPositionList',
    mixins: [JeecgListMixin],
    components: {
      DataManagementModal,
      JDictSelectTag,
      moment
    },
    data() {
      return {
        // description: '职务表管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '数据编码',
            align: 'center',
            dataIndex: 'code'
          },
          {
            title: '数据名称',
            align: 'center',
            dataIndex: 'name'
          },
          {
            title: '数据类型',
            align: 'center',
            dataIndex: 'sysOrgCode'
          },
          {
            title: '数据来源',
            align: 'center',
            dataIndex: 'createBy'
          },
          {
            title: '数据状态',
            align: 'center',
            dataIndex: 'postRank_dictText',
            scopedSlots: { customRender: 'dataStatus' },
          },
          {
            title: '接入时间',
            align: 'center',
            dataIndex: 'createTime',
            // scopedSlots: { customRender: 'createTime' },
            customRender: (text) => {
                if(text !== '' && text !== null){
                  return moment(text).format('YYYY-MM-DD HH:mm:ss')
                }else{
                  return ''
                }
                
              }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: '/sys/position/list',
          delete: '/sys/position/delete',
          deleteBatch: '/sys/position/deleteBatch',
          exportXlsUrl: '/sys/position/exportXls',
          importExcelUrl: 'sys/position/importExcel',
        },
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      handleDetail(record){
        this.$router.push({
        path: "/isystem/dataManagement/detail",
        query: {
          id: record.id
        }
      });
      }
    }
  }
</script>
<style lang="less" scoped>
  /** Button按钮间距 */
  .ant-btn {
    margin-left: 3px
  }

  .ant-card-body .table-operator {
    margin-top: 18px;
  }

  .ant-table-tbody .ant-table-row td {
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .anty-row-operator button {
    margin: 0 5px
  }

  .ant-btn-danger {
    background-color: #ffffff
  }

  .ant-modal-cust-warp {
    height: 100%
  }

  .ant-modal-cust-warp .ant-modal-body {
    height: calc(100% - 110px) !important;
    overflow-y: auto
  }

  .ant-modal-cust-warp .ant-modal-content {
    height: 90% !important;
    overflow-y: hidden
  }
</style>
